//1. 安装
//2. 导入
const mongoose = require("mongoose");

//3. 连接 mongodb 数据库
mongoose.connect("mongodb://127.0.0.1:27017/h5220707");

//4. 设置回调  on  when 当...时候
mongoose.connection.on("open", () => {
  //5. 声明文档结构对象 
  const MovieSchema = new mongoose.Schema({
    name: String,
    actors: Array,
    releaseYear: Number,
  });

  //6. 创建文档模型对象
  const MovieModel = mongoose.model("movie", MovieSchema);

  //7. 文档操作
  //更新操作          条件,  数据,  回调
  // MovieModel.updateOne({_id: '632e80b2a3f5eb8aa3156d9d'}, {name: '英雄本色'}, (err,data) => {
  //   if(err) throw err;
  //   console.log(data);

  //   //
  //   mongoose.connection.close();
  // })

  MovieModel.updateMany({name: '大话西游'}, {actors: ['周星驰','吴孟达','朱茵','莫文蔚']}, (err,data) => {
    if(err) throw err;
    console.log(data);

    //
    mongoose.connection.close();
  })
  
  
});

/**
 * 1. 更改密码
 * 2. 更新个人信息
 * 3. 更新价格
 */

